package com.zatech.cgnci.project.controller.statement;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zatech.cgnci.project.base.utils.ConvertUtils;
import com.zatech.cgnci.project.dto.*;
import com.zatech.cgnci.project.entity.CgnciCodeTypeDO;
import com.zatech.cgnci.project.service.CgnciContractInvoiceService;
import com.zatech.cgnci.project.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 合约账单信息 前端控制器
 * </p>
 *
 * @author Generator
 * @since 2024-12-30
 */
@RestController
@RequestMapping("/api/contract-tnvoice")
@Api(produces = "application/json", tags = "合约账单管理api接口文档")
@RequiredArgsConstructor
public class CgnciContractInvoiceController {

    private final CgnciContractInvoiceService contractInvoiceService;


    @PostMapping("/pageQuery")
    @ApiOperation(value = "分页列表查询")
    public IPage<ContractInvoiceVO> pageHigherCode(@RequestBody ContractInvoiceQueryDTO queryDTO) {
        return contractInvoiceService.pageQuery(queryDTO);
    }

    @GetMapping("/findById")
    @ApiOperation(value = "详情")
    public ContractInvoiceDetailsVO findCodeTypeByIdAndNumber(Long id, String invoiceNumber) {
        return contractInvoiceService.getDetails(id,invoiceNumber);
    }

    @PostMapping("/add")
    @ApiOperation(value = "新增")
    @Transactional(rollbackFor = Exception.class)
    public void add(@RequestBody @Valid ContractInvoiceAddDTO addDTO) {
        contractInvoiceService.addContractInvoice(addDTO);
    }

    @PostMapping("/update")
    @ApiOperation(value = "更新")
    @Transactional(rollbackFor = Exception.class)
    public void update(@RequestBody ContractInvoiceUpdateDTO updateDTO) {
        contractInvoiceService.updateContractInvoice(updateDTO);
    }

    @PostMapping("/updateUpm")
    @ApiOperation(value = "更新UPM")
    public void updateUpm(@RequestBody ContractInvoiceUpmUpDTO updateDTO) {
        contractInvoiceService.updateUpm(updateDTO);
    }

    @GetMapping("/queryBusiness")
    @ApiOperation(value = "查询合约分入分出名称列表")
    public List<CgnciBusinessInsurancePageVO> queryBusiness() {
        return contractInvoiceService.queryBusiness();
    }

    @GetMapping("/queryReinsurer")
    @ApiOperation(value = "查询合约再保人列表")
    public ReinsuranceVO queryReinsurer(Long insuranceId) {
        return contractInvoiceService.queryReinsurer(insuranceId);
    }

    @GetMapping("/del")
    @ApiOperation(value = "删除")
    @Transactional(rollbackFor = Exception.class)
    public void del(Long id,String invoiceNumber) {
        contractInvoiceService.delete(id,invoiceNumber);
    }
}

